<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <title>批量上传二维码</title>
    <script th:src="@{/static/jquery3.js}"></script>
    <script th:src="@{/static/jquery-form.js}"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#uploadBotton").click(function () {
                if(confirm("确认上传？")){
                    var imagePath = $("#codes").val();
                    if (imagePath == "") {
                        alert("请上传文件",2);
                        return false;
                    }
                    var strExtension = imagePath.substr(imagePath.lastIndexOf('.') + 1);
                    if (strExtension!='xlsx') {
                        if (strExtension!='xls') {
                            if (strExtension!='xlsm') {
                                alert("请上传EXCEL文件",2);
                                return false;
                            }
                        }
                    }

                    $("#uploadForm").ajaxSubmit({
                        type : 'POST',
                        url : 'qrcode/upload',
                        success : function(result) {
                            if(result.success=='yes'){
                                alert(result.message);
                            }else{
                                alert(result.message);
                            }
                        },
                        error : function() {
                            alert("上传失败，请检查网络后重试,上传文件太大");
                        }
                    });
                }
            })
        });
    </script>
</head>
<body style="padding: 10px">
<div align="center">
        <h1>批量上传二维码</h1>
    <form id="uploadForm" enctype="multipart/form-data" method="post">
        <h2><input type="file" id="codes" name="excelFile" capture="camera" aria-describedby="basic-addon4"  />
            <button type="button" id="uploadBotton">上 传</button></h2>
    </form>
</div>
</body>
</html>